﻿/*********************************************************************************************************************
Unit tests VanguardDocumentation, Create Objects

© 2014 Erik Ackerholm

This file is part of SqlVanguard.

SqlVanguard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later 
version.

SqlVanguard is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SqlVanguard. If not, see 
<http://www.gnu.org/licenses/>.
*********************************************************************************************************************/

set nocount on;
set xact_abort off;
GO

use [master];
GO

drop database VdUnitTest;
GO

create database VdUnitTest
on
	primary (name = N'VdUnitTest_Primary', filename = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\DATA\VdUnitTest_Primary.mdf'),
	filegroup TESTFILES (name = N'VdUnitTest_Test', filename = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\DATA\VdUnitTest_Test.ndf')
log on (name = N'VdUnitTest_Log', filename = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL2008R2\MSSQL\DATA\VdUnitTest_Log.ldf');
GO

use VdUnitTest;
GO

create schema TestSchema;
GO

create user TestUser without login;
GO

create table TestSchema.TestTable (
	TestID       integer not null        identity (1, 1),
	TestCol      nvarchar(50)
		constraint DF_TestTable_TestCol default 'Test',

	constraint PK_TestTable primary key clustered (TestID),
	constraint UQ_TestTable unique (TestCol),
	constraint CK_TestTable_TestColNotEmpty check (rtrim(TestCol) <> '')
);
GO

create user WriterA without login;
execute sp_addrolemember 'VanguardDocumentationWriter', 'WriterA';
GO

create user ReaderB without login;
execute sp_addrolemember 'VanguardDocumentationReader', 'ReaderB';
GO

create user NormalUserC without login;
GO
























































